#!/bin/bash

RPM_PKGS="{{ init_system_packages.rpm | join(' ') }}"
DEB_PKGS="{{ init_system_packages.deb | join(' ') }}"

cd /air-gapped

if [ -f /usr/bin/dnf ]; then
  /usr/bin/dnf install -y yum-utils
  repotrack --destdir /air-gapped/ $RPM_PKGS
elif [ -f /usr/bin/yum ]; then
  /usr/bin/yum install -y yum-utils
  repotrack --destdir /air-gapped/ $RPM_PKGS
elif [ -f /usr/bin/apt ]; then
  /usr/bin/apt-get update
  /usr/bin/apt-get install -y apt-transport-https
  /usr/bin/apt-get download $DEB_PKGS
else
  echo "Unsupported package manager"
  exit 1
fi
